//将0翻转，最长1的个数
public class leetcode1004 {
    public int longestOnes(int[] nums, int k) {
        int left=0;
        int right=0;
        int zero=0;
        int len=0;
        while(right<nums.length){
            if(nums[right]==1){
                right++;
            }else{
                zero++;
                right++;
            }
            while(zero>k){
                if(nums[left]==0){
                    zero--;
                }
                left++;
            }
            len=Math.max(len,(right-left));
        }
        return len;


    }
}
